using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml;

[WebService]
public class Suds : WebService {
    [WebMethod]
    public int compute(int a) {
        try {
            return fib(a);
        }
        catch (Exception e) {
            throw seanfoy.oopsnet.SOAPErrorHandler.toSoapException(e);
        }
    }
    public int fib(int i) {
        try {
            return oddfib(i, 0, 1);
        }
        catch (Exception e) {
            throw
                new ArgumentException(
                    String.Format(
                        "The {0}th Fibonacci number is odd.",
                        i),
                    "i",
                    e);
        }
    }
    public int oddfib(int i, int a, int b) {
        if (i == 0) {
            if (a % 2 == 0) {
                throw new Exception(String.Format("{0} is even.", a));
            }
            return a;
        }
        return oddfib(i - 1, b, a + b);
    }
}
